package com.ptswitch.material.util;

import java.util.HashMap;
import java.util.Map;

import org.hxzon.util.OgnlUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ColumnMap extends HashMap<String, Integer> {

    protected static final Logger logger = LoggerFactory.getLogger(OgnlUtil.class);
    private static final long serialVersionUID = -923130710708693539L;
    private static final Map<String, String> consts = new HashMap<String, String>();

    static {
        init();
    }

    public static void init() {
        // materiel
        consts.put("品牌", "brand");
        consts.put("物料编号", "code");
        consts.put("器件描述", "description");
        consts.put("器件封装", "footprint");
        consts.put("物料名称", "name");
        consts.put("pcb封装", "pcbDecal");
        consts.put("备注", "remark");
        consts.put("品牌", "brand");
        consts.put("规格型号", "specification");
        consts.put("供货商", "supplier");
        //
        consts.put("封装", "footprint");// alias
        consts.put("供应商", "supplier");// alias
        consts.put("状态", "state");// alias
        // bom

        // bomMateriel
        consts.put("code", "code");
        consts.put("designator", "designator");
        consts.put("comment", "comment");
        consts.put("footprint", "footprint");
        consts.put("value", "value");
        consts.put("voltage", "voltage");
        consts.put("quantity", "quantity");
        consts.put("stuff_opt", "stuffOpt");
        consts.put("stuffopt", "stuffOpt");// alias
    }

    public Integer put(String key, Integer value) {
        String midkey = consts.get(key.toLowerCase());
        if (midkey != null) {// fixme
            return super.put(midkey, value);
        } else {
//			logger.error("{0} not found", key);
            return -1;
        }
    }

    public Integer get(Object key) {

        Integer index = super.get(key);
        if (index != null) {
            return index;
        } else {
//			logger.error("{0} not found", key);
            return -1;
        }
    }

}
